//
//  YKHelpDocumentsViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/11/2.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKHelpDocumentsViewController.h"
#import "YKHelpDocumentModel.h"
#import <TFWebViewController.h>
@interface YKHelpDocumentsViewController ()

@end

@implementation YKHelpDocumentsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"帮助文档";
    // Do any additional setup after loading the view.
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.top.trailing.equalTo(self.view);
        
    }];
    
    self.dataSource.totalPageKey = @"page.totalpage";
    self.dataSource.currentPageKey = @"curpage";
    
    [self startLoadData];
}

- (NSDictionary *)pageViewControllerParameters {
    return @{
             kTFPageViewControllerRequestParameter:@{@"title":@""},
             kTFPageViewControllerItemClass:[TFTitleDetailItem class],
             kTFPageViewControllerModelClass:[YKHelpDocumentModel class],
             kTFPageViewControllerRequestURL:@"personalCentr/searchHelpDocumentList.htm",
             kTFPageViewControllerDataKeyPath:@"list"
             };
}

- (void)customizeItem:(TFTitleDetailItem *)item {
    item.title = [item.model TITLE];
    item.titleWidth = self.view.frame.size.width - 16;
    item.cellHeight = 44.f;
    item.selectionHandler = ^(__kindof TFTitleDetailItem *i, NSIndexPath *indexPath) {
        
        [TFHTTPMANAER POST:@"personalCentr/searchShopArticleById.htm" parameters:@{@"article_id": [i.model ARTICLE_ID] } HUD:@"" success:^(id responseObject) {
            YKHelpDocumentModel *model = [YKHelpDocumentModel yy_modelWithJSON:responseObject[@"article"]];
            TFWebViewController *vc = [[TFWebViewController alloc]init];
            vc.title = model.TITLE;
            vc.html = model.CONTENT;
            [self.navigationController pushViewController:vc animated:YES];
            
        } failure:^(id responseObject, NSError *error) {
            
        }];
        
    };
}

@end
